//
//  XMN_PostImageCell.m
//  B段项目
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 谢美娜. All rights reserved.
//

#import "XMN_PostImageCell.h"
#import "Header.h"

@implementation XMN_PostImageCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _titleLabel = [[myTitleLabel alloc]init];
        [self addSubview:_titleLabel];
        
        _contentLabel = [[myContectLabel alloc]init];
        _contentLabel.numberOfLines = 0;
        _contentLabel.textColor = [UIColor grayColor];
        [self addSubview:_contentLabel];
        
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel.textColor = [UIColor grayColor];
        [self addSubview:_timeLabel];
        
        _covImageView = [[UIImageView alloc]init];
        [self addSubview:_covImageView];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    _titleLabel.frame = CGRectMake(20 * FitWidth, 10 * FitHeight, self.contentView.frame.size.width - 30 * FitWidth, 20 *FitHeight);
    _covImageView.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 10 * FitHeight, 80 * FitWidth, 80 *FitHeight);
    _contentLabel.frame = CGRectMake(_covImageView.frame.origin.x + _covImageView.frame.size.width + 10 * FitWidth, _covImageView.frame.origin.y, self.contentView.frame.size.width - 40 * FitWidth - _covImageView.frame.size.width, 80 * FitHeight);
    _timeLabel.frame = CGRectMake(_covImageView.frame.origin.x, _covImageView.frame.origin.y + _covImageView.frame.size.height + 10 * FitHeight, 200 * FitWidth, 15 * FitHeight);
}

-(void)setPosts:(XMN_Posts *)posts{
    _titleLabel.text = posts.title;
    _contentLabel.text = posts.content;
    [_covImageView sd_setImageWithURL:[NSURL URLWithString:posts.coverimg]];
    [_covImageView sd_setImageWithURL:[NSURL URLWithString:posts.coverimg] placeholderImage:[UIImage imageNamed:@"XMN_Shequ_Cell"]];
    _timeLabel.text = [NSString stringWithFormat:@"发表时间: %@", posts.addtime_f];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
